package priv.pront.code.robot;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-07-28 14:34
 */
public class P9412_购物 {

    static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static int n;
    static int[] a;

    public static void main(String[] args) throws IOException {
        st.nextToken();
        n = (int) st.nval;
        a = new int[n];
        for (int i = 0; i < n; i++) {
            st.nextToken();
            a[i] = (int) st.nval;
        }

        if(n == 1 || (n == 2 && a[1] == 2 && a[0] == 1)){
            System.out.println(-1);
            return;
        }
        for (int i = 1; i < n; i++) {
            int pre = a[i - 1];
            int cur = a[i];
            if(cur > pre + 1){
                System.out.println(cur);
                break;
            }
        }
    }
}
